#!/usr/bin/env python

from pyhpwsgi.impl.app import PyHPApp
from pyhpwsgi.impl.framework import PyHPFrameWork

application = PyHPApp ()
application = PyHPFrameWork ( application )
	
if __name__ == '__main__':
	import sys

	def start_wsgi_server ( port ):
		global application

		from wsgiref.simple_server import make_server

		try:
			from os3.externals.firepython.middleware import FirePythonWSGI
			application = FirePythonWSGI ( application )
		except:
			raise
			pass

		httpd = make_server ( '', port, application )
		httpd.serve_forever ()

	try:
		port = int ( sys.argv [ 1 ] )
	except:
		port = 8000

	print "Server UP on port %s" % port
	start_wsgi_server ( port )
